package vertxZeebe.jobworker;

import io.vertx.core.json.JsonObject;
import io.zeebe.client.ZeebeClient;
import io.zeebe.client.api.response.ActivatedJob;
import io.zeebe.client.api.worker.JobClient;
import io.zeebe.client.api.worker.JobHandler;

public class RJobWorker implements JobHandler {
    ZeebeClient zeebeClient;

    public RJobWorker(ZeebeClient zeebeClient) {
        this.zeebeClient = zeebeClient;
    }

    @Override
    public void handle(JobClient client, ActivatedJob job) {
        System.out.println("开始执行RJobWorker");

        JsonObject data=new JsonObject(job.getVariables());
        String res1=data.getString("res1");
        String res2=data.getString("res2");
        String res3=data.getString("res3");

        System.out.println(String.format("打印3个任务的结果：res1=%s,res2=%s,res3=%s",res1,res2,res3));
        client.newCompleteCommand(job.getKey())
                .send()
                .join();
    }
}
